//
//  ScreentoneView.m
//  OperationPro
//
//  Created by Mac on 2016/10/14.
//  Copyright © 2016年 展鸿科技. All rights reserved.
//

#import "ScreentoneView.h"
#import "ScreentoneCell.h"
#import "ScreentoneModel.h"

@interface ScreentoneView()
@property(nonatomic)BOOL isCommon;

@end
@implementation ScreentoneView

- (void)initView{
    [super initView];
    self.backgroundColor=BackColor;
    [self registerCell:[ScreentoneCell class] withModel:[ScreentoneModel class]];
    [self setTableActionType:CTableActionType_Both];
    self.perPageCount = 15;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [super tableView:tableView cellForRowAtIndexPath:indexPath];
    cell.selectionStyle =UITableViewCellSelectionStyleNone;
    UILabel *line =[cell viewWithTag:100];
    line.backgroundColor =LineColor;
    cell.backgroundColor =[UIColor clearColor];
    cell.textLabel.textColor =[UIColor whiteColor];


    return cell;
}
- (void)showCommon
{
    self.isCommon=YES;
    //常用机构
    [self setDataWithUrl:@"select_showCommonInstSelect" andParam:@{@"customerType":@"02"}];
    [self setShowNoDataNotice:@"你没有常用的机构"];
    [self refresh];


}
- (void)setDicParam:(NSDictionary *)dicParam{
    self.isCommon=NO;
    [self setDataWithUrl:@"select_showInstSelect" andParam:dicParam];
    [self setShowNoDataNotice:@"未搜寻到相关机构"];
    [self refresh];
}
- (void)reloadData
{
    if (self.isCommon==YES) {
        if(self.mainData.count==0)
        {
            self.tableHeaderView=nil;
            
        }else
        {
            self.tableHeaderView=[self headView];
            
        }
    }else
    {
        self.tableHeaderView=nil;
        
    }
    [super reloadData];
    
}
- (UIView *)headView
{
    UIView *headView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, WindowWidth, 40)];
    headView.backgroundColor=[UIColor clearColor];
    UILabel *line =[[UILabel alloc]initWithFrame:CGRectMake(25, 40-0.5, WindowWidth-25, 0.5)];
    line.backgroundColor =LineColor;
    [headView addSubview:line];
    UILabel *lab =[[UILabel alloc]initWithFrame:CGRectMake(25, 0,WindowWidth-35, 40-0.5)];
    lab.textColor=C(@"999999");
    lab.font =F(15);
    [headView addSubview:lab];
    lab.text=@"常用的机构";
    return headView;
}

@end
